<template>
  <div class="pageWrap">
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="页面名称">
        <el-input v-model="formInline.user" placeholder="请输入页面名称或者id"></el-input>
      </el-form-item>
      <el-form-item label="页面创建者">
        <el-select v-model="formInline.region" placeholder="页面创建者">
          <el-option label="区域一" value="shanghai"></el-option>
          <el-option label="区域二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
        <router-link to="/addPage">
            <el-button @click="onSubmit">新建页面</el-button>
        </router-link>
        <router-link to="/addModule">
            <el-button @click="onSubmit">新建模块</el-button>
        </router-link>
      </el-form-item>
    </el-form>
    <div class="list">
       <el-table :data="tableData" style="width: 100%">
      <el-table-column prop="id" label="id" width="180"></el-table-column>
      <el-table-column prop="name" label="页面名称" width="180"></el-table-column>
      <el-table-column prop="router" label="页面路由"></el-table-column>
      <el-table-column prop="type" label="类型"></el-table-column>
      <el-table-column prop="open_ssr" label="ssr"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
            <router-link :to="`/canvas?id=${scope.row.id}`">
                <el-button type="text" size="small">进入</el-button>
            </router-link>
            <router-link :to="`/addPage?id=${scope.row.id}`">
                <el-button type="text" size="small">编辑</el-button>
            </router-link>
            <el-button size="small" type="text">删除</el-button>
        </template>
        
      </el-table-column>
    </el-table>
    </div>
   
    <div class="page">
      <el-pagination @current-change="handleChange(val)"
      background
      layout="prev, pager, next"
      :total="1000">
    </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "list",
  data() {
    return {
        page: 1,
        pageSize: 20,
        formInline: {
          id: '',
          author: ''
        },
        tableData: [],
    };
  },
  methods: {
    handleChange(val){
      console.log(val)
    },
    onSubmit() {
        console.log(123)
    },
    init(){
      this.$http.post("/page/list",{}).then((res) => {
        if(res.success){
          this.tableData = res.data;
        }
      })  
    }
  },
  mounted() {
    this.init()
  },
};
</script>
<style lang="stylus" scoped>
.pageWrap
    padding 20px
    .list
      min-height 500px
    .page
      margin 20px auto
      text-align center
</style>

 